<template>
  <yy-paging
    v-model="dataList"
    @query="queryList"
    ref="paging"
    :auto="automatic"
    @scroll="scroll"
    :refresher-enabled="false"
  >
    <template #top>
      <u-navbar
        :is-back="false"
        :background="{ backgroundColor: isScroll ? '#F2F5F7' : 'transparent' }"
        :border-bottom="false"
        :custom-style="{ transition: 'background-color 0.3s ease-in-out' }"
      >
        <view class="grid grid-cols-3 items-center px-3 w-full">
          <view class="flex col-span-1 items-center" @click="vk.navigateBack()">
            <image src="/static/dddr128.png" mode="aspectFill" class="size-6" />
          </view>
          <view class="line-clamp-1 flex col-span-1 justify-center">
            <view class="text-[#000] font-bold text-base"> 设置 </view>
          </view>
          <view class="flex col-span-1 justify-end">
            <view class="text-[14px] text-[#5C6068]"> </view>
          </view>
        </view>
      </u-navbar>
    </template>
    <template #empty>
      <yy-empty></yy-empty>
    </template>
    <template #loadingMoreNoMore>
      <yy-nomore></yy-nomore>
    </template>
    <view class="flex flex-col gap-3 p-4">
      <!--  -->
      <view class="rounded-[.5rem] bg-white">
        <view class="flex justify-between px-5 py-3" @click="vk.navigateTo('/pages/my/changeBinding')">
          <view class="text-[.875rem] text-[#161A24]">手机号绑定 </view>
          <view class="flex gap-1 items-center">
            <view class="text-[.875rem] text-[#8E9299]"
              >{{ vk.pubfn.hidden(vk.getVuex('$user.userInfo.mobile'), 3, 4) }}
            </view>
            <u-icon name="arrow-right" size="26" color="#8E9299"></u-icon>
          </view>
        </view>
        <view class="flex justify-between px-5 py-3" @click="goBindPayment()">
          <view class="text-[.875rem] text-[#161A24]">支付宝收款 </view>
          <view class="flex gap-1 items-center">
            <view class="text-[.875rem] text-[#8E9299]">{{ vk.pubfn.isNull(data) ? '去绑定' : '已绑定' }}</view>
            <u-icon name="arrow-right" size="26" color="#8E9299"></u-icon>
          </view>
        </view>
      </view>
      <view class="rounded-[.5rem] bg-white">
        <view class="flex justify-between px-5 py-3" @click="vk.navigateTo('/pages/my/logOff')">
          <view class="text-[.875rem] text-[#161A24]">注销帐号 </view>
          <view> <u-icon name="arrow-right" size="26" color="#8E9299"></u-icon> </view>
        </view>
      </view>
    </view>
  </yy-paging>
</template>

<script>
  export default {
    data() {
      return {
        isScroll: false, // 是否滚动
        dataList: [], // 数据列表
        automatic: false, // 是否自动加载
        data: {} // 数据对象
      }
    },

    onShow() {
      this.getWithdrawalAccount()
    },
    methods: {
      goBindPayment() {
        const url = this.data?.accounts
          ? `/pages/my/alipay?accounts=${this.data.accounts}&id=${this.data.id}`
          : '/pages/my/bindAlipay'

        vk.navigateTo({
          url
        })
      },
      scroll(e) {
        this.isScroll = e.detail.scrollTop > 0
      },
      async queryList(page, limit) {
        this.$refs.paging.complete([1, 1, 1])
      },
      async getWithdrawalAccount() {
        let res = await api.getWithdrawalAccount()
        this.data = res.data
      }
    }
  }
</script>

<style lang="scss" scoped></style>
